<html lang="en">
<head>
    <title>大家都在看</title>
    <#include "../common/header.ftl">
    <script type="text/javascript" src="/js/plugins/jquery.form.js"></script>


    <script>
        $(function () {
            $(".inputBtn").click(function () {
                //所属攻略的回显
                var specialSubCommendId = $('#specialSubCommendSelect').val();
                var specialSubCommendTitle = $('#specialSubCommendSelect option:selected').html();
                if(specialSubCommendId==-1){
                    $.messager.alert("温馨提示","请选择一个分栏");
                    return;
                }
                $("#editForm input[name='specialSubCommendTitle']").val(specialSubCommendTitle);
                $("#editForm input[name='specialSubCommendId']").val(specialSubCommendId);

                //通过地区攻略id获取游记数据
                $.get("/subfieldSpecialSell/getCatalogBigBypId.do",{specialSubCommendId:specialSubCommendId},function (data) {
                    var html="<option value='-1'>"+'--请选择--'+"</option>";
                    $.each(data,function (index,item) {
                        html+="<option value='"+item.id+"'>"+item.name+"</option>"
                    })
                    $("#cbTwoSelect").html(html);
                });
                $("#editForm select[name='cbTwoId']").change(function () {
                    var cbTwoId = $('#cbTwoSelect').val();
                    $.get("/subfieldSpecialSell/getCatalogDetailBycbId.do",{cbTwoId:cbTwoId},function (data) {
                        console.log(data);
                        var html="<option value='-1'>"+'--请选择--'+"</option>";
                        $.each(data,function (index,item) {
                            html+="<option value='"+item.id+"'>"+item.title+"</option>"
                        })
                        $("#ticketSelect").html(html);
                    });
                });

                $("#editModal").modal("show");
            });

            $(".submitBtn").click(function () {
                $("#editForm").ajaxSubmit(function (data) {
                    if(data.success){
                        $.messager.confirm("温馨提示","操作成功",function () {
                            window.location.href="/subfieldSpecialSell/Looklist.do";
                        })
                    }else{
                        $.messager.alert("温馨提示",data.msg);
                    }
                })
            });
        });
    </script>
</head>
<body>
<!--左侧菜单回显变量设置-->
<#assign currentMenu="subfieldSpecialSell">

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-2">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-10">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">分栏特卖</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/subfieldSpecialSell/Looklist.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>攻略搜索:</label>
                    <select name="specialSubCommendId" class="form-control" id="specialSubCommendSelect">
                        <option value="-1">--请选择--</option>
                        <#list specialSubCommends as s>
                            <option value="${s.id}">${s.name}</option>
                        </#list>
                    </select>
                    <script>
                        $("#specialSubCommendSelect").val(${specialSubCommendId!});
                    </script>
                </div>
                <button id="btn_query" class="btn btn-info"><span class="glyphicon glyphicon-search"></span> 查询</button>
                <a href="javascript:;" class="btn btn-success inputBtn" id="addStrategyBtn">更新特卖</a>
            </form>

            <table class="table table-striped table-hover" >
                <thead>
                    <tr>
                        <th>特卖门票</th>
                    </tr>
                </thead>
                <#if list??>
                    <#list list as entity>
                       <tr>
                           <td>${(entity.landmarkDetai.title)!}</td>
                           <td><img src="${(entity.landmarkDetai.coverURL)!}" width="60px"></td>

                           <td>${entity.stateDispaly!}</td>
                       </tr>
                    </#list>
                </#if>
            </table>
        </div>
    </div>
</div>

<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/subfieldSpecialSell/insertRelation.do" method="post" id="editForm">
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">所属类别：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="specialSubCommendTitle" readonly>
                            <input type="hidden" class="form-control" name="specialSubCommendId"  value="">
                        </div>
                    </div>
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">关联分类专题：</label>
                        <div class="col-sm-6">
                            <select name="cbTwoId" class="form-control" id="cbTwoSelect">
                            </select>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">分类专题门票：</label>
                        <div class="col-sm-6">
                            <select name="ticketId" class="form-control" id="ticketSelect">
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary submitBtn">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>